﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using LDataAccess;
using LModels;
using Proxy = LModels.Proxy.Proxy;

namespace Models
{
    public abstract class BaseModel : IModel
    {
        private long id;
        protected Proxy px;

        public BaseModel()
        {
        }

        public BaseModel(Proxy pxProxy)
        {
            px = pxProxy;
        }

        public long ID
        {
            get
            {
                long? ret = GetPK();
                if (ret.HasValue)
                    return ret.Value;
                
                return -1;
            }
        }

        
        protected long? GetPK()
        {
            return id;
        }

        protected void SetPK(long PrimaryKey)
        {
            id = PrimaryKey;
        }

        protected internal abstract BaseModel Load(long key);


        public void ResetLazyObjects()
        {
            
        }
    }

}
